//解题思路为翻转后去除头部的空格然后计数即可
class Solution {
public:
    int lengthOfLastWord(string s) {
        reverse(s.begin(),s.end());
        int i = 0;
        while(s[i] == ' ')
        {
            i++;
        }
        int len = 0;
        while(i<s.size()&&s[i]!=' ')
        {
            i++;
            len++;
        }
        
        return len;
    }
};